<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="frm.ssh.util.page.SearchBean"%>
<%@ include file="/jsp/common/common.jsp"%>
<html>
	<head>
		<script language="javascript" src="<%=contextPath%>/js/func.js"type=""></script>
		<script type="text/javascript" src="<%=contextPath%>/js/My97DatePicker/WdatePicker.js"></script>
		
		<script language="javascript" src="<%=contextPath%>/ext3/examples/ux/ColumnHeaderGroup.js"type=""></script>
		<link rel="stylesheet" type="text/css" href="<%=contextPath%>/ext3/examples/ux/css/ColumnHeaderGroup.css" />
	</head>
	<body style="margin: 0;overflow:hidden"> 
	<script type="text/javascript">
		Ext.onReady(function(){
			
			  Ext.QuickTips.init();
			  
			  var xg = Ext.grid;
			  var expand=false; 
			  var statusdata=[['0','未提交'],['1','已提交 ']];
			  var strWindowURL="<%=contextPath%>/jsp/business/plan/selectStation.jsp";
			  
			  var statusSelect=new Ext.form.ComboBox({
				    fieldLabel:'状态',
				    width : 200,
				    store:new Ext.data.SimpleStore({
				     fields:['value','text'],
				     data:statusdata
				    }),
				    emptyText:'请选择',
				    mode:'local',
				    triggerAction:'all',
				    valueFiled:'value',
				    displayField:'text',
				    width : 120,
				    readyOnly:true
			 }); 
				 
			 var selectStationWin = new Ext.Window({
		    		title   : "选择 变电站",
		    		width   : 460,
		    		height   : 478,
		    		closable   : true,
		    		modal   : true,
		    		plain   : true,
		    		//maximizable : true,
		    		draggable   : false,
		    		html   : '<iframe  src="' + strWindowURL + '" width="100%" marginwidth="0" height="100%" marginheight="0" scrolling="no" frameborder="0"></iframe>'
		    	});
			   
			  var    fields = [
			                    {type: 'int', name: 'BeijingProductX'},
			                    {type: 'int', name: 'BeijingProductY'},
			                    {type: 'int', name: 'TokyoProductX'},
			                    {type: 'int', name: 'TokyoProductY'},
			                    {type: 'int', name: 'BerlinProductX'},
			                    {type: 'int', name: 'BerlinProductY'},
			                    {type: 'int', name: 'LondonProductX'},
			                    {type: 'int', name: 'LondonProductY'},
			                    {type: 'int', name: 'LondonProductY2'},
			                    {type: 'int', name: 'ParisProductX'},
			                    {type: 'int', name: 'ParisProductY'},
			                    {type: 'int', name: 'LondonProductX1'},
			                    {type: 'int', name: 'LondonProductY1'},
			                    {type: 'int', name: 'ParisProductX1'},
			                    {type: 'int', name: 'ParisProductY1'},
			                    {type: 'int', name: 'ParisProductX2'},
			                    {type: 'int', name: 'ParisProductY2'}
			                   ],
				    columns = [ {dataIndex: 'BeijingProductX', header: '序号'},
				                {dataIndex: 'BeijingProductY', header: '开始时间'},
				                {dataIndex: 'TokyoProductX', header: '结束时间'},
				                {dataIndex: 'TokyoProductY', header: '变电站'},
				                {dataIndex: 'BerlinProductX', header: '停电范围'},
				                {dataIndex: 'BerlinProductY', header: '电压等级'},
				                {dataIndex: 'LondonProductX', header: '设备类别'},
				                {dataIndex: 'LondonProductY', header: '工作项目'},
				                {dataIndex: 'LondonProductY2', header: '总负责人'},
				                {dataIndex: 'ParisProductX', header: '负责人'},
				                {dataIndex: 'ParisProductY', header: '成员'},
				                {dataIndex: 'LondonProductX1', header: '负责人'},
				                {dataIndex: 'LondonProductY1', header: '成员'},
				                {dataIndex: 'ParisProductX1', header: '负责人'},
				                {dataIndex: 'ParisProductY1', header: '成员'},
				                {dataIndex: 'ParisProductX2', header: '负责人'},
				                {dataIndex: 'ParisProductY2', header: '成员'}],
				    data = [],
				    arr = [];
              		for(var i = 0; i < 20; ++i){
                  		arr.push((Math.floor(Math.random()*18) + 1) * 100000);
              		}
                    data.push(arr);
				   	topGroupRow = [
								{},
							   	{},
							   	{},
								{},
								{},
								{},
								{},
								{},
								{ header: '工作组织', colspan: 9, align: 'center' }],
				    groupRow = [{},
							   	{},
							   	{},
								{},
								{},
								{},
								{},
								{},
								{ header: '多班组', colspan: 1, align: 'center' },
								{ header: '变电检修班', colspan: 2, align: 'center' },
								{ header: '变压器班', colspan: 2, align: 'center' },
								{ header: '继电保护班', colspan: 2, align: 'center' },
								{ header: '试验油务班', colspan: 2, align: 'center' }];
				     
				
				    
				    var searchform = new Ext.form.FormPanel({
					     labelAlign : 'right',
					     buttonAlign : 'center',
					     bodyStyle:'background-color:#FFFFFF;border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
					     border:false,
					     width: 855,
					     labelWidth : 60,
					     frame : true,
					     defaults: {
					            anchor: '0'
					     },
					     el:'form',
					     items: [{
						        layout:'column',                  //定义该元素为布局为列布局方式
						        border:false,
						        bodyStyle:'border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
						        labelSeparator:'：',
						        items:[{
						            columnWidth:.5,               //该列占用的宽度，标识为50％
						            layout: 'form',
						            bodyStyle:'border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
						            border:false,
						            items: [{                     //这里可以为多个Item，表现出来是该列的多行
						                width : 200,
						                xtype:'textfield',
						                fieldLabel: '变电站',
						                name: 'searchBean.con2',
						                listeners:{
						                	'focus': function(){
						            			selectStationWin.show();  
						                   } 
			                            } 
						            },{                           //这里可以为多个Item，表现出来是该列的多行
						                width : 200,
						                xtype:'textfield',
						                fieldLabel: '电压等级',
						                name: 'searchBean.con3'
						            }]
						        },{
						            columnWidth:.5,
						            layout: 'form',
						            bodyStyle:'border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
						            border:false,
						            items: [statusSelect,
								            {	xtype: 'compositefield',
						                		fieldLabel: '日期范围',
						                		msgTarget : 'side',
						                		anchor    : '-20',
						                		defaults: {
						                    		flex: 1
						                		},
						                		items: [{
						                        	xtype: 'datefield',
						                        	name : 'startDate',
							                        format:'Y-m-d'
						                    	},{
						                        	xtype: 'datefield',
						                        	name : 'endDate',
						                        	format:'Y-m-d'
						                    	}]
						            }]
						        }]
						    }],
					     tbar : [{
					    	 pressed : true,
						     text:'新建',
						     icon:contextpath + '/images/add.gif',
						     handler:function(){
					    	 	newPlanFormWin.show();
					     	}
						  }, '-',{
							 pressed : true,
						     text:'删除',
						     icon:contextpath + '/images/delete.gif',
						     ref: '../removeButton',
						     disabled: true
						  },'->',{
							    pressed : true,
						       	text : '查询',
						       	icon:contextpath + '/images/query.gif',
						        handler : function() {
						            if(!expand){ //当查询表展开时，设置查询表单的高和grid的高
						             document.getElementById('form').style.height = "120px";
						             document.getElementById('form').style.overflow = "visible";
						             grid.setHeight(document.body.clientHeight-1);
						             form.setHeight(120);
						             expand=true;
						            }else{    //当查询表收缩时，设置查询表单的高和grid的高
						                document.getElementById('form').style.height = "34px";
						                document.getElementById('form').style.overflow = "hidden";
						                grid.setHeight(document.body.clientHeight);
						                form.setHeight(34);
						                expand=false;
						            }
						      }
						   }],
						   bbar:{width: '100%',
					    	 	items:['->'
					    	            ,{
					    	            	pressed : true,
					    	                xtype: 'tbbutton',
					    	                text: '确定',
					    	                width: 80
					    	            },{
					    	                xtype: 'tbspacer',
					    	                width: 10
					    	            },{
					    	            	pressed : true,
					    	                xtype: 'tbbutton',                
					    	                text: '重置',
					    	                width: 80
					    	            }]  
					     } 
					});
				    var newPlanForm = new Ext.form.FormPanel({
						  frame:true,
						  autoHeight:true,	
						  width:600,
						  labelWidth:80,
						  items:[{
							  xtype:"fieldset",
							  title:"基本信息",
							  autoHeight:true,			//使自适应展开排版
							  items:[{
								  layout:'column',
						          border:false,
						          items:[{
								  	columnWidth:.5,
								  	layout: 'form',
								    border:false,
								    items: [{
								    	 xtype:'datefield',
						                 fieldLabel: '开始日期',
						                 name: 'startdate',
						                 format:'Y-m-d',
						                 anchor:'95%'
					                   
					                },{
					                   
					                    xtype:'textfield',
							            fieldLabel: '变电站',
							            name: 'stationname',
							            anchor:'95%'
					                },{
					                    xtype:'textfield',
							            fieldLabel: '停电范围',
							            name: 'powerrange',
							            anchor:'95%'
					                }]
						          },{
									  	columnWidth:.5,
									  	layout: 'form',
									    border:false,
									    items: [{
									    	xtype:'datefield',
						                    fieldLabel: '结束日期',
						                    format:'Y-m-d',
						                    name: 'enddate',
						                    anchor:'95%'
						                   
						                }, {
						                    
						                    xtype:'textfield',
								            fieldLabel: '电压等级',
								            name: 'voltagelevel',
								            anchor:'95%'
						                },{
						                    xtype:'textfield',
								            fieldLabel: '设备类别',
								            name: 'etype',
								            anchor:'95%'
						                }]
						          }]
							  },{ 
								  columnWidth:1,
								  xtype:'textfield',
						          fieldLabel: '工作项目',
						          name: 'workcontent',
						          anchor:'97.5%'
							  },{ 
								  columnWidth:1,
								  xtype:'textfield',
						          fieldLabel: '备注',
						          name: 'remarks',
						          anchor:'97.5%'
							  }]
								  	
						  },{
								  xtype:"fieldset",
								  id:'gzzz_fs',
								  title:"工作组织",
								  hidden:true,
								  collapsible: true,
								  collapsed: true,
								  autoHeight:true,			//使自适应展开排版
								  items:[{
									  xtype:"fieldset",
									  title:"变电检修班",
									  autoHeight:true,	
									  items:[{
									         layout:'column',
									         border:false, 
									         items: [{
										  			columnWidth:.5, 
										  			layout: 'form',
										  			items: [{
										  					xtype:'textfield',
											  				fieldLabel:"负责人",
											  				name:"bdfzr",
											  				 anchor:'95%'
										  			}]
									         	  },{
									        		columnWidth:.5, 
													layout: 'form',
													items: [{
														    xtype:'textfield',
													  		fieldLabel:"工作班成员",
													  		name:"bdgzzcy",
													  		anchor:'95%'
												 	}]
									             }]
									     }]
									  },{
										  xtype:"fieldset",
										  title:"变压器班",
										  autoHeight:true,	
										  items:[{
										         layout:'column',
										         border:false, 
										         items: [{
											  			columnWidth:.5, 
											  			layout: 'form',
											  			items: [{
											  					xtype:'textfield',
												  				fieldLabel:"负责人",
												  				name:"bdfzr",
												  				 anchor:'95%'
											  			}]
										         	  },{
										        		columnWidth:.5, 
														layout: 'form',
														items: [{
															    xtype:'textfield',
														  		fieldLabel:"工作班成员",
														  		name:"bdgzzcy",
														  		anchor:'95%'
													 	}]
										             }]
										     }]
										  },{
											  xtype:"fieldset",
											  title:"继电保护班",
											  autoHeight:true,	
											  items:[{
											         layout:'column',
											         border:false, 
											         items: [{
												  			columnWidth:.5, 
												  			layout: 'form',
												  			items: [{
												  					xtype:'textfield',
													  				fieldLabel:"负责人",
													  				name:"bdfzr",
													  				 anchor:'95%'
												  			}]
											         	  },{
											        		columnWidth:.5, 
															layout: 'form',
															items: [{
																    xtype:'textfield',
															  		fieldLabel:"工作班成员",
															  		name:"bdgzzcy",
															  		anchor:'95%'
														 	}]
											             }]
											     }]
											  },{
												  xtype:"fieldset",
												  title:"试验班",
												  autoHeight:true,	
												  items:[{
												         layout:'column',
												         border:false, 
												         items: [{
													  			columnWidth:.5, 
													  			layout: 'form',
													  			items: [{
													  					xtype:'textfield',
														  				fieldLabel:"负责人",
														  				name:"bdfzr",
														  				 anchor:'95%'
													  			}]
												         	  },{
												        		columnWidth:.5, 
																layout: 'form',
																items: [{
																	    xtype:'textfield',
																  		fieldLabel:"工作班成员",
																  		name:"bdgzzcy",
																  		anchor:'95%'
															 	}]
												             }]
												     }]
												  }]
								  },{
									  xtype:"fieldset",
									  title:"工作监督",
									  id:'gzjd_fs',
									  hidden:true,
									  collapsible: true,
									  collapsed: true,
									  autoHeight:true,	
									  items:[{
									         layout:'column',
									         border:false, 
									         items: [{
										  			columnWidth:.5, 
										  			layout: 'form',
										  			items: [{
										  					xtype:'textfield',
											  				fieldLabel:"到位人员",
											  				name:"bdfzr",
											  				 anchor:'95%'
										  			}]
									         	  },{
									        		columnWidth:.5, 
													layout: 'form',
													items: [{
														    xtype:'textfield',
													  		fieldLabel:"验收人员",
													  		name:"bdgzzcy",
													  		anchor:'95%'
												 	}]
									             }]
									  }]
								  }],
						tbar:{
							 width: '100%',
							 items:[{
								pressed : true,
								text : '保存',
								icon:contextpath + '/images/save.gif',
							    handler:function(){
						    	 	
						     	}
							},'-',{
								pressed : true,
								text : '提交（至审核班组安排）',
								icon:contextpath + '/images/save.gif',
							    handler:function(){
						    	 	
						     	}
							},'-',{
								pressed : true,
								text : '填写工作组织',
								icon:contextpath + '/images/remark.gif',
							    handler:function(){
								 Ext.getCmp('gzzz_fs').show();
						     	}
							},'-',{
								pressed : true,
								text : '填写工作监督',
								icon:contextpath + '/images/remark.gif',
							    handler:function(){
								 Ext.getCmp('gzjd_fs').show();
						     	}
							},'-',{
								pressed : true,
								text : '关闭',
								icon:contextpath + '/images/delete.gif',
							    handler:function(){
						    	 	
						     	}
							}]
					  }
					});
				    var newPlanFormWin = new Ext.Window({
					  	title   : "生产计划",
			    		width:615,
			    		autoHeight :true,	
			    		closable   : true,
			    		modal      : true,
			    		buttonAlign : 'center',
			    		plain   : true,
			    		items:[newPlanForm]
				  });
				  var group = new Ext.ux.grid.ColumnHeaderGroup({
				        rows: [topGroupRow, groupRow]
				    });
				    
				  var sm = new xg.CheckboxSelectionModel({
				        listeners: {
				            selectionchange: function(sm) {
				                if (sm.getCount()) {
				                	searchform.removeButton.enable();
				                } else {
				                	searchform.removeButton.disable();
				                }
				            }
				        }
				    });
				    var grid = new Ext.grid.GridPanel({
				    	el : 'grid',
				        layout:'fit',
				        region:'center', 
				        bodyStyle:'width:100%;height:100%',
				        title: '起草月度计划',
				        width: 1000,
				        autoheight: true,
				        autoScroll: true,  
				        store: new Ext.data.ArrayStore({
				            fields: fields,
				            data: data
				        }),
				        columns: columns,
				        viewConfig: {
				            forceFit: true
				        },
				        plugins: group,
				        bbar: new Ext.PagingToolbar({  
				            //store: SalesAnastore,  
				           // pageSize: pageSize,  
				            //显示右下角信息  
				            displayInfo: true,  
				            displayMsg: '当前记录 {0} -- {1} 条 共 {2} 条记录',  
				            emptyMsg: "没有记录",  
				            prevText: "上一页",  
				            nextText: "下一页",  
				            refreshText: "刷新",  
				            lastText: "最后页",  
				            firstText: "第一页",  
				            beforePageText: "当前页",  
				            afterPageText: "共{0}页"
				        }),
				        tbar:[searchform]    //加到grid的工具栏上
				    });

				    document.getElementById('form').style.height = "34px";
					document.getElementById('form').style.overflow = "hidden";
					grid.setHeight(document.body.clientHeight);
					grid.render();
			  
		});
		</script>
			<div id="form" style="width:100%;height:35;font-size:0;"></div>
			<div id="grid" style="width:100%;height:100%;"></div>		
        </div> 
	</body>
</html>

